<?php
$id				= gpc_getIntPost("id",$id);
$parentId       = gpc_getIntPost("ParentId");
$name			= gpc_getStringPost("Name");
$TopBottomOrder	= gpc_getIntPost("TopBottomOrder",-1);
$order			= gpc_getIntPost("Order",-1);
$status			= gpc_getIntPost("Status");
$Description    = gpc_getStringPost("Description");
$ImgIntro 		= gpc_getStringPost('ImgIntro');
$Description    = replace_pathlocal($Description);

if($parentId==0)
{
	error_transfer("Please select Category");
}else if(empty($name))
{
	error_transfer("Please enter Name");
}

//get order category same parent;
$order=GetOrderForInsert($TopBottomOrder,$order,$parentId,"tblsettourelm");


if($act=="insertcontent")
{
    $sql_insert = "INSERT INTO tblsettourelm
    	(iParentId,cName,cImage,cDescription,cInclusion,cOtherInclusion,iOrder,iStatus)
    VALUES
    	($parentId,'$name','$ImgIntro','$Description','','','$order','$status')";

    $dbsql->query($sql_insert);

	Insert_Tracking("add Program Tour : $name");
	page_transfer("Add Program Tour $name Success !","opt=addcontent&id=$parentId");
}
elseif($id>0)
{
	$sql_update = "UPDATE tblsettourelm SET ";
    $sql_update.= "iParentId	 	= $parentId, ";
    $sql_update.= "cName 			= '$name', ";
    $sql_update.= "cImage 			= '$ImgIntro', ";
    $sql_update.= "cDescription	    = '$Description', ";
    $sql_update.= "cInclusion 		= '', ";
    $sql_update.= "cOtherInclusion	= '', ";
    if($order>0)
    {
        $sql_update.= "iOrder       = $order, ";
    }
    $sql_update.= "iStatus          = $status ";
	$sql_update.= "WHERE iId        = $id";

	$dbsql->query($sql_update);

	Insert_Tracking(" Edit Program Tour : $name");
	page_transfer("Update Program Tour Success !","opt=element&id=$parentId");
}
exit();
?>